﻿Public Class ThayDoiPassword
    Private Function SoSanhChuoi(ByVal passmoi As String, ByVal nhaplaiPassmoi As String) As Boolean
        Dim giaTri As Boolean
        giaTri = Equals(passmoi, nhaplaiPassmoi)
        Return giaTri
    End Function

    Private Sub btnDangKy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDangKy.Click
        Dim nguoicu As New KiemTraUsername_DTO
        Dim nguoimoi As New KiemTraUsername_DTO
        Dim passmoi As String = txtPassMoi.Text
        Dim nhaplaippassmoi As String = txtNhapLaiPass.Text
        nguoicu.UserName = txtUsername.Text
        nguoimoi.UserName = txtUsername.Text
        nguoicu.Password = txtPassword.Text

        If Equals(nguoicu.UserName, "") = True Or Equals(nguoicu.PassWord, "") = True Or Equals(passmoi, "") = True Or Equals(nhaplaippassmoi, "") = True Then
            MessageBox.Show("bạn hãy điền đầy đủ thông tin")
        Else
            Dim i As Boolean = KiemTraNguoiDangNhap_BUS.KiemTraDangNhap(nguoicu)
            If i = True Then
                Dim k As Boolean = SoSanhChuoi(passmoi, nhaplaippassmoi)
                If k = True Then
                    nguoimoi.PassWord = passmoi
                    KiemTraNguoiDangNhap_BUS.DoiPass(nguoimoi)
                Else
                    MessageBox.Show("Bạn nhập lại pass mới không đúng")
                End If
            Else
                MessageBox.Show("tài khoảng này không tồn tại")
            End If
        End If
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class